﻿using SmartRFIDSystem.dao;
using SmartRFIDSystem.Model;
using System.Net;
using System.Net.Mail;
using static System.Net.Mime.MediaTypeNames;

namespace RegisterForm
{
    public partial class RegisterForm : Form
    {
        public RegisterForm()
        {
            InitializeComponent();
        }

        private void Form2_Load(object sender, EventArgs e)
        {

        }

        private void SendIdCode_Click(object sender, EventArgs e)
        {
            //Mail.MailSystem.SendMail("2422914906@qq.com", "subtest", "body");
            //// 发送方信息
            //const string smtpserver = "smtp.exmail.qq.com";
            //const string senderemail = "skygod@skygodnet.cn";
            //const string senderpassward = "pkgxghxgxrbcub22";

            //try
            //{
            //    // 设置 smtpclient
            //    var smtpclient = new smtpclient(smtpserver, 465)
            //    {
            //        // 启用ssl
            //        enablessl = true,
            //        // 设置发送人的信息
            //        credentials = new networkcredential(senderemail, senderpassward)
            //    };

            //    // 创建mailmessage
            //    mailmessage mailmessage = new()
            //    {
            //        // 设置发件人地址
            //        from = new mailaddress(senderemail)
            //    };
            //    // 设置收件人地址
            //    //test
            //    mailmessage.to.add("2422914906@qq.com");
            //    // 设置邮件主题
            //    mailmessage.subject = "this is subject";
            //    // 设置邮件内容
            //    mailmessage.body = "this is body";
            //    // 发送邮件
            //    smtpclient.send(mailmessage);
            //}
            //catch (exception ex)
            //{
            //    messagebox.show(ex.message);
            //}
        }

        private void submit_Click(object sender, EventArgs e)
        {
            UserDao user = new UserDao();
            if(user.register(UserName.Text,PassWord.Text,Email.Text) == 1)
            {
                this.Close();
            }
            

        }
    }
}
